// FillBlankQuestion.java
package com.scuec.groupfive.entity;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class FillBlankQuestion {
    private Long id;
    private Long questionId;
    private String blanks; // JSON格式的填空位置和答案
    private List<String> blanksList; // 解析后的列表
    private String answerTemplate;
    private String analysis;

    public void setBlanksList(List<String> blanksList) {
        this.blanksList = blanksList;
    }

    // 可以添加一个方法来解析blanks
    public void parseBlanks() {
        if (this.blanks != null && !this.blanks.isEmpty()) {
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                this.blanksList = objectMapper.readValue(this.blanks, new TypeReference<List<String>>() {});
            } catch (Exception e) {
                e.printStackTrace();
                this.blanksList = new ArrayList<>();
            }
        }
    }
}